package com.smartStatus.admin.activemq;

import com.alibaba.fastjson.JSONObject;
import com.smartStatus.admin.service.SysUserService;
import com.smartStatus.api.entity.SysUser;
import com.smartStatus.core.util.R;
import com.smartStatus.security.annoation.Ignore;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * @Author: liuby5
 * @CreateTime: 2022-09-01  17:14
 * @Description:
 * @Version: 1.0
 */
@RestController
@RequestMapping("/mq-test")
public class MqTestController {
    @Resource
    private ActiveMqUtils activeMqUtils;

    @Resource
    private SysUserService sysUserService;

    @Ignore(value = false)
    @GetMapping("/send-msg/{msg}")
    public R sendMsg(@PathVariable("msg") String msg) {
        SysUser byId = sysUserService.getById(1);
        String message = JSONObject.toJSONString(byId);
        activeMqUtils.sendMsg("first-queue", message);
        activeMqUtils.sendMsg("second-queue",message);
        return R.ok();
    }
}
